package net.nohaven.proj.javeau.ui.fw;

import java.awt.Component;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import net.nohaven.proj.javeau.crypt.prng.PRNG;

public abstract class TypedLeftClickListener<E extends Component> implements
		MouseListener {
	public abstract void action(E subject);

	public void mouseClicked(MouseEvent arg0) {
		PRNG.getInstance().tick();
	}

	public void mouseEntered(MouseEvent arg0) {
		PRNG.getInstance().tick();
	}

	public void mouseExited(MouseEvent arg0) {
		PRNG.getInstance().tick();
	}

	public void mousePressed(MouseEvent arg0) {
		PRNG.getInstance().tick();
	}

	@SuppressWarnings("unchecked")
	public void mouseReleased(MouseEvent arg0) {
		if (arg0.getButton() != MouseEvent.BUTTON1 || arg0.getClickCount() > 1)
			return;
		action((E) arg0.getComponent());
	}

}
